#include <iostream>
#include <atomic>
#include <thread>
#include <vector>
#include <unistd.h>
#include <assert.h>

std::atomic<int> a(0);
std::atomic<int> b(0);

int ValueSet()
{
    int t = 1;
    a.store(t, std::memory_order_relaxed);
    b.store(2, std::memory_order_relaxed);
    return 0;
}

int Oberserver()
{
    while (b.load(std::memory_order_relaxed) != 2)
        ;
    assert(a.load(std::memory_order_relaxed) == 1);
    return 0;
}

int main()
{
    a = 0;
    b = 0;
    std::thread t2(Oberserver);
    std::thread t1(ValueSet);
    t1.join();
    t2.join();

    // std::cout << "a:" << a << "; b:" << b << std::endl;
    return 0;
}